<template>
	<view class="">
		<view class="box">
			<view class="head-tit">填写学生证</view>
			<view class="content">
				<view class="con-tit">姓名</view>
				<input class="con-txt" v-model="form.stu_name" placeholder="请填写姓名" placeholder-style="color:#BFBFBF"/>
			</view>
			<view class="content">
				<view class="con-tit">学历</view>
				<view class="con-txt" @click="showEdu=true">
					<input disabled v-model="form.edu_type_name" placeholder="请选择学历" placeholder-style="color:#BFBFBF" />
					<text>选择</text>
				</view>
			</view>
			<view class="content">
				<view class="con-tit">学校</view>
				<view class="con-txt" @click="showSchcool=true">
					<input disabled v-model="form.school_name" placeholder="请填写学校" placeholder-style="color:#BFBFBF" />
					<text>选择</text>
				</view>
			</view>
			<view class="content">
				<view class="con-tit">院系</view>
				<input class="con-txt" v-model="form.department_name" placeholder="请填写院系" placeholder-style="color:#BFBFBF" />
			</view>
			<view class="content">
				<view class="con-tit">专业</view>
				<input class="con-txt" v-model="form.major" placeholder="请填写专业" placeholder-style="color:#BFBFBF" />
			</view>
			<view class="content">
				<view class="con-tit">入学时间</view>
				<view class="con-txt" @click="showTime=true">
					<input disabled v-model="form.enter_school_time" placeholder="请选择入学时间" placeholder-style="color:#BFBFBF" />
					<text>选择</text>
				</view>
			</view>
		</view>
		<view class="dl" @click="submit">
			<view class="dll">提交</view>
		</view>
		<u-calendar v-model="showTime" :mode="mode" @change="change" max-date="2100-01-01"></u-calendar>
		<u-select mode="single-column" v-model="showEdu" :list="eduList" @confirm="confirm"></u-select>
		<u-select mode="single-column" v-model="showSchcool" :list="schoolList" @confirm="confirmSchool"></u-select>
		<u-toast ref="uToast"/>
	</view>
</template>

<script>
	export default{
		components:{
			
		},
		data(){
			return{
				form:{
					major:'',
					stu_name:'',
					edu_type:'',
					school_id:'',
					school_name:'',
					edu_type_name:'',
					department_name:'',
					enter_school_time:'',
				},
				eduList:[],
				mode: 'date',
				schoolList:[],
				showEdu:false,
				showTime: false,
				showSchcool:false,
			}
		},
		onLoad() {
			this.getSchool()
			this.getEdutype()
		},
		methods:{
			async getSchool(){
				const res = await this.get('/index/Index/get_all_school')
				res.data.forEach((item,i) =>{
					this.schoolList.push({value:i+1,label:item.school_name})
				})
			},
			async getEdutype(){
				const res = await this.get('/Index/index/config')
				let res2 = res.data.school_edu_type
				for(var i in res2){
					this.eduList.push({value:i,label:res2[i]})
				}
			},
			async submit(){
				const res = await this.post('/Index/User/save_school_student',this.form)
				if(res.code==200){
					uni.showToast({
						title:'提交成功',
						duration:1000,
						success:() => {
							setTimeout(() => {
							    uni.navigateTo({
							    	url:'./student_card'
							    })
							},1000)
						}
					})
				}else{
					uni.showToast({
						title:'提交失败'
					})
				}
			},
			change(e) {
				this.form.enter_school_time = e.result;
			},
			confirm(e){
				this.form.edu_type=e[0].value
				this.form.edu_type_name=e[0].label
			},
			confirmSchool(e){
				this.form.school_id=e[0].value
				this.form.school_name=e[0].label
			}
		}
	}
</script>

<style lang="scss" scoped>
	.dl {
		width: 100%;
		padding: 30rpx;
		position: fixed;
		bottom: 10rpx;
		left: 50%;
		transform: translateX(-50%);
		.dll {
			width: 100%;
			height: 90rpx;
			background-color: #3291F8;
			line-height: 90rpx;
			text-align: center;
			border-radius: 15rpx;
			color: #FFFFFF;
			font-size: 36upx;
		}
	}
	.box {
		padding: 30rpx;
		box-sizing: border-box;
		.head-tit{
			color: #101010;
			font-size: 48upx;
			font-weight: bold;
			margin-bottom: 36upx;
		}
		.content {
			border-bottom: 1rpx solid #E6E6E6;
			padding: 10rpx 0;
			.con-tit{
				color: #101010;
				font-size: 32upx;
				margin: 15upx 0;
			}
			.con-txt{
				display: flex;
				justify-content: space-between;
				font-size: 36upx;
				margin-top: 25upx;
				input{
					font-size: 36upx;
				}
				text{
					color: #3291F8;
				}
			}
		}
	}
</style>